<?php

/**
 * Transaction form base class.
 *
 * @method Transaction getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTransactionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'doctor_billing_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('DoctorBilling'), 'add_empty' => true)),
      'amount'            => new sfWidgetFormInputText(),
      'type'              => new sfWidgetFormChoice(array('choices' => array('Auto' => 'Auto', 'Manual' => 'Manual'))),
      'is_finalized'      => new sfWidgetFormInputCheckbox(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'doctor_billing_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('DoctorBilling'), 'required' => false)),
      'amount'            => new sfValidatorNumber(),
      'type'              => new sfValidatorChoice(array('choices' => array(0 => 'Auto', 1 => 'Manual'), 'required' => false)),
      'is_finalized'      => new sfValidatorBoolean(array('required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('transaction[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Transaction';
  }

}
